<?php
$mu = Session::get('mu');
$u = new Model('qy_party_confings');
$u->find(['pid'=>$mu->id]);
$conf = (new Model('qy_party_confings'))->find(["isadmin"=>1]);
if($u->try_post()){
  if(!$u->id){
    $u->pid = $mu->id;
    $u->isadmin = $mu->isadmin;
    if(!$mu->isadmin == 1){
      $u->token = $conf->token;
      $u->EncodingAESKey = $conf->EncodingAESKey;
    }
    $u->ctime = time();
  }
  $u->save();
  tusi('设置成功');
}
$zlUlr = getHost();
$commonUrl = getCommonUrl();
function getHost() {
  return getHttp() . '://' . $_SERVER['HTTP_HOST'] . '/Addons/QyWechat/Api/Providers/ThirdParty/index.html';
}
function getCommonUrl() {
  return getHttp() . '://' . $_SERVER['HTTP_HOST'] . '/Addons/QyWechat/Api/Providers/ThirdParty/client.html';
}
function getHttp() {
  if (strtolower(explode('://', $_SERVER['HTTP_REFERER'])[0]) == 'https') {
    return 'https';
  }
  if (strtolower($_SERVER['REQUEST_SCHEME']) == 'https') {
    return 'https';
  }
  return 'http';
}